class LocalTalkRecordModel {
  int id;
  String fromId;
  String toId;
  int createtime;
  String text;
  String memberNickname;
  String memberHead;
  int read;

  LocalTalkRecordModel(
      {this.id,
      this.fromId,
      this.toId,
      this.createtime,
      this.text,
      this.memberNickname,
      this.memberHead,
      this.read});

  LocalTalkRecordModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    fromId = json['from_id'];
    toId = json['to_id'];
    text = json['text'];
    memberNickname = json['member_nickname'];
    memberHead = json['member_head'];
    read = json['read'];

    if (json['createtime'] is int) {
      createtime = json['createtime'];
    } else if (json['createtime'] is String) {
      createtime = int.parse(json['createtime']);
    } else if (json['createtime'] == null) {
      final time = (DateTime.now().millisecondsSinceEpoch / 1000).floor();
      createtime = time;
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['from_id'] = this.fromId;
    data['to_id'] = this.toId;
    data['createtime'] = this.createtime;
    data['text'] = this.text;
    data['member_nickname'] = this.memberNickname;
    data['member_head'] = this.memberHead;
    data['read'] = this.read ?? 0;
    return data;
  }
}
